//***********************************************************



public class Person
{
	
	private String ssn,firstName,lastName,adress, telefon;
	private int siffra, kon;
	private boolean isok;
	final static int MAN = 1;
	final static int WOMEN = 2;
	public Person(String ss)
	{
         isok = false;
	if(ss !=null && (!ss.equals("")))
		{
        	ssn = ss;
	
		if(ss.length() == 10)
		{
                siffra = Character.digit(ss.charAt(8),10);
		if(siffra % 2 == 0)
	  	kon = WOMEN;
		else kon = MAN;
		// "hamburger".substring(4, 8) returns "urge"
 		//"smiles".substring(1, 5) returns "mile"

		//6508010615
		ssn = ssn.substring(0,6) + "-"+ssn.substring(6,10);
		isok = true;
		}
        
		else if(ss.length() == 11)
		{
		siffra = Character.digit(ss.charAt(9),10);
		if(siffra % 2 == 0)
	  	kon = WOMEN;
		else kon = MAN;
		isok = true;
		}
	
		}
	}

	public String getSSN()
	{
	if(ssn != null)
	 return ssn;
        else return "";
	}
 	
	public boolean isOK()
	{
	return isok;
	}

	public boolean setFirstName(String ss)
	{
	if(ss != null && (!ss.equals("")))
	{
        firstName = ss;
	return true;
	}
  	else
  	 return false;
	}

	public String getFirstName()
	{
	if(firstName != null)
		return firstName;
        else return " ";
	}
	
	public boolean setLastName(String ss)
	{
	if(ss != null && (!ss.equals("")))
	{
        lastName = ss;
	return true;
	}
  	else
  	 return false;
	}
	
	public String getLastName()
	{
	if(lastName != null)
		return lastName;
        else return " ";
	}

	public boolean setAddress(String ss)
	{
	if(ss != null && (!ss.equals("")))
	{
        adress = ss;
	return true;
	}
  	else
  	 return false;
	}
	
	public String getAddress()
	{
	if(adress != null)
		return adress;
        else return " ";
	}
	
 	public boolean setPhone(String ss)
	{
	if(ss != null && (!ss.equals("")))
	{
        telefon = ss;
	return true;
	}
  	else
  	 return false;
	}
	
	public String getPhone()
	{
	if(telefon != null)
		return telefon;
        else return " ";
	}
	
	public boolean isMale()
	{
	if(kon == 1)
	return true;
	else
	return false;
	}
	
	public boolean isFemale()
	{
	if(kon == 2)
	return true;
	else
	return false;
	}
	public String toString()	//metoden returnerar person-objekts samtliga data
	{
	String ss = lastName+ "  "+firstName;
		return ss;
	}
}

